﻿<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.researchsubject.domain.*" pageEncoding="UTF-8"%>
<%@page import="com.hs.core.page.PageUtil,com.hs.core.utils.*,cn.ac.cintcm.dataconverge.researcher.domain.*"%>
<%@page import="cn.ac.cintcm.dataconverge.util.Constants,cn.ac.cintcm.dataconverge.util.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
PageUtil pageUtil = (PageUtil)request.getAttribute("subjectList");
List resultList = null;
String pageStr = ""; 
int perpageCount = 1;
int currentPage = 1;
if(null != pageUtil){
   resultList = pageUtil.getPageList();
   pageStr = pageUtil.getPageStr();
   perpageCount = pageUtil.getNumberPerPage();
   currentPage = pageUtil.getCurrentPage();
}
String subjectname = (String)request.getAttribute("subjectname");
String startdate = (String)request.getAttribute("startdate");
String enddate = (String)request.getAttribute("enddate");
String startyear = (String)request.getAttribute("startyear");
String endyear = (String)request.getAttribute("endyear");
String snumber = (String)request.getAttribute("snumber");
String status = (String)request.getAttribute("status");

String onreserach = (String)request.getAttribute("onreserach");
String onpermit = (String)request.getAttribute("onpermit");
String finishSubject = (String)request.getAttribute("finishSubject");

String orderName = (String)request.getAttribute("orderName");
String orderNum = (String)request.getAttribute("orderNum"); 
String orgId = (String)request.getAttribute("orgId"); 
List orgList = (List)request.getAttribute("orgList");
List dictList = (List)request.getAttribute("dictList");
String subjectUser = (String)request.getAttribute("subjectUser");

String comeFromId = (String)request.getAttribute("comeFromId");
String studyTagId = (String)request.getAttribute("studyTagId");
String reasearchNavId = (String)request.getAttribute("reasearchNavId");
String reasearchPropId = (String)request.getAttribute("reasearchPropId");
String studyDict = (String)request.getAttribute("studyDict");
String isDoc = (String)request.getAttribute("isDoc");
Researcher researcher = (Researcher) request.getSession().getAttribute(
		Constants.USER_IN_SESSION);
boolean isAdmin = AuthCheck.isAdmin(researcher);
boolean isOrgLeader = AuthCheck.isInGroup(request,Constants.ORG_LEADER);
boolean authFlag = false; 
if(isAdmin ||isOrgLeader )
	authFlag = true;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>课题信息</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> 
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link href="<%=path%>/index/Themes/com/style.css" rel="stylesheet" type="text/css" /> 
    <script src="<%=path%>/index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
     <script src="<%=path%>/js/common.js" language="javascript" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript">
       function delSubject(id){
       		if(null != id && id != '' ){
       		 	if(confirm("确认删除课题?")){
       		 		form1.action = '<%=path%>/subjectToAdd.htm?action=delSubject&id='+id;
       		 		form1.submit();
       		 	}
       		}
       
       }
       function searchSubject(){ 
       	
       			searchform.submit();			
       }
       
    </script>
 
</head>
<body class="rtm_body" scroll=yes>
<form name="searchform" action = "<%=path%>/subject.htm?action=listAllSubjects" method="post">
    <input type="hidden" value="<%=comeFromId%>" name="comeFromId" id="comeFromId">
    <input type="hidden" value="<%=studyTagId%>" name="studyTagId" id="studyTagId">
    <input type="hidden" value="<%=reasearchNavId%>" name="reasearchNavId" id="reasearchNavId">
    <input type="hidden" value="<%=reasearchPropId%>" name="reasearchPropId" id="reasearchPropId">
    <div class="r_rtm_tb_mg1">
        <div class="r_rtm_tb1">
            <span>
                <img src="<%=path%>/index/Themes/com/idt_tb_pass.gif" />&nbsp;&nbsp;课题查询</span>
        </div>
    </div>    
       <!-- <div>
        <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
            <tr>
                <td class="fim_r" align="right" colspan="8">
                    <fieldset class="com_fieldset" align="center">
                        <legend class="com_legend">课题信息概览</legend>
                        <table border="0" cellpadding="0" cellspacing="1" width="100%" class="com_fieldset_tab">
                            <tr>
                                <td class="fim_l" width="10%" align="center">
                                    在研：</td>
                                <td class="fim_r" align="center">
                                   <font color="red"><%=onreserach %></font>个</td>
                                <td class="fim_l" width="10%" align="center">
                                    中标：</td>
                                <td class="fim_r" align="center">
                                    <font color="red"><%=onpermit %></font>个</td>
                                <td class="fim_l" width="10%" align="center">
                                    已结题：</td>
                                <td class="fim_r" align="center">
                                    <font color="red"><%=finishSubject %></font>个</td>
                            </tr>
                             
                        </table>
                    </fieldset>
                </td>
            </tr>
        </table>
    </div> -->
     <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
        <tr>
            <td class="fim_l" width="10%">
                课题名称：</td>
            <td class="fim_r" width="25%">
                <input type="text" name="subjectname" value="<%=subjectname==null?"":subjectname %>" class="com_textbox" ></td>
            <!-- td class="fim_l">
                申报日期：</td>
            <td class="fim_r" nowrap width="30%">
                从
               <input type="text" class="Wdate" id="startdate" value="<%=startdate==null?"":startdate %>" style="width:40%" name="startdate"  onFocus="WdatePicker({el:'startdate',dateFmt:'yyyy-MM-dd'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="enddate" value="<%=enddate==null?"":enddate %>" style="width:40%" name="enddate"  onFocus="WdatePicker({el:'enddate',dateFmt:'yyyy-MM-dd'})" />
            </td-->
            <td class="fim_l" width="10%">
                完成单位：</td>
            <td class="fim_r" nowrap width="25%">
               <select name="orgId" style="width:100%">
                <option value=""></option>
                <%
                
                 if(orgList.size()>0){ 
                	 for(int i =0;i<orgList.size();i++){
                		 Organization org = (Organization)orgList.get(i);
                		 out.print("<option value=");
                		 out.print(org.getId());
                		 if((org.getId()+"").equals(orgId))
                		 	out.print(" selected");
                		 out.print(">");
                		 out.print(org.getName());
                		 out.print("</option>");
                	 }
                 }
                %>
                </select>
            </td>
            <td class="fim_l" width="10%">
               重点学科</td>
            <td class="fim_r" width="25%"> 
                  <select name="studyDict" style="width:100%">
                   <option value=""> </option>
                   <%
                     if(null != dictList && dictList.size()>0){
                    	 for(int i =0;i<dictList.size();i++){
                    		 SystemDict dict = (SystemDict)dictList.get(i);
                    		 out.println("<option value=");
                    		 out.println(dict.getId());
                    		 if((dict.getId()+"").equals(studyDict)){
                    			 out.println(" selected");
                    		 }
                    		 out.println(">");
                    		 out.println(dict.getName());
                    		 out.println("<option>");
                    	 }
                     } 
                   %>
                  
                  </select>
            </td>
        </tr>
        <tr>
            <td class="fim_l">
                课题负责人：</td>
            <td class="fim_r">
                <input type="text" name="subjectUser" value="<%=subjectUser==null?"":subjectUser %>" class="com_textbox" id="Text2" name="Text2"></td>
            
            <td class="fim_l">
                课题状态：</td>
            <td class="fim_r" nowrap width="30%">
               <select name="status" style="width:100%">
                 <option value="-1">----请选择----</option>
                 <option value="<%=Constants.subject_state_save%>" <%if((""+Constants.subject_state_save).equals(status)){out.println(" selected");} %>>未提交审批</option>
                 <option value="<%=Constants.subject_state_apply%>" <%if((""+Constants.subject_state_apply).equals(status)){out.println(" selected");} %>>申报中</option>
                  <option value="<%=Constants.subject_state_advised%>" <%if((""+Constants.subject_state_advised).equals(status)){out.println(" selected");} %>>推荐中标</option>
                   <option value="<%=Constants.subject_state_checked%>" <%if((""+Constants.subject_state_checked).equals(status)){out.println(" selected");} %>>中标</option>
                  <option value="<%=Constants.subject_state_researching%>" <%if((""+Constants.subject_state_researching).equals(status)){out.println(" selected");} %>>在研</option>
                 <option value="<%=Constants.subject_state_endApply%>" <%if((""+Constants.subject_state_endApply).equals(status)){out.println(" selected");} %>>申请结题</option>
                
                   <option value="<%=Constants.subject_state_ended%>" <%if((""+Constants.subject_state_ended).equals(status)){out.println(" selected");} %>>已结题</option>
                   <option value="<%=Constants.subject_state_unchecked%>" <%if((""+Constants.subject_state_unchecked).equals(status)){out.println(" selected");} %>>未中标</option>
                   <option value="<%=Constants.subject_state_retuen%>" <%if((""+Constants.subject_state_retuen).equals(status)){out.println(" selected");} %>>退回修改</option>
                 
                </select>  
            </td>
            <td class="fim_r" align="right" colspan="2">
                <input type="submit" value="查询"  onclick="searchSubject()" class="com_btn2" id="Button5">
                <input type="button" value="高级查询"   onclick="if(AdCheckForm.style.display=='none')AdCheckForm.style.display='';else AdCheckForm.style.display='none';"
                    class="com_btn2" id="Button1">
                
            </td>
        </tr>
        <tr id="AdCheckForm" style="display: none;">
            <td class="fim_l">
                学位：</td>
            <td class="fim_r">
                <select name="snumber" style="width:95%">
		       		<option value="">全部</option>
			  		<option value="1" <%if("1".equals(snumber)){out.println(" selected");} %>>本科</option>
			  		<option value="2" <%if("2".equals(snumber)){out.println(" selected");} %>>硕士</option>
					<option value="3" <%if("3".equals(snumber)){out.println(" selected");} %>>博士</option>
					<option value="4" <%if("4".equals(snumber)){out.println(" selected");} %>>博士后</option>
					<option value="5" <%if("5".equals(snumber)){out.println(" selected");} %>>中专</option>
					<option value="6" <%if("6".equals(snumber)){out.println(" selected");} %>>大专</option>
					<option value="7" <%if("7".equals(snumber)){out.println(" selected");} %>>其它</option>
			 	  </select>
			 	  </td>
            <td class="fim_l">
                所属年份：</td>
            <td class="fim_r">
                从
               <input type="text" class="Wdate" id="startyear" value="<%=startyear==null?"":startyear %>" style="width:40%" name="startyear"  onFocus="WdatePicker({el:'startyear',dateFmt:'yyyy'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="endyear" value="<%=endyear==null?"":endyear %>" style="width:40%" name="endyear"  onFocus="WdatePicker({el:'endyear',dateFmt:'yyyy'})" />
            </td>
            <td class="fim_l">
              是否有附件： </td>
            <td class="fim_r"> 
                  <select name="isDoc" style="width:100%">
                  <option value=""> </option>
                  <option value="0" <%if("0".equals(isDoc)){ out.println(" selected");} %>>有附件</option>
                  <option value="1" <%if("1".equals(isDoc)){ out.println(" selected");} %>>无附件</option>
                  
                  </select>
            </td>
        </tr>
        </form>
    </table> 
   
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <div class="content">
                 <form name="form1" action="" method="post">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4"> 
                        <tr> 
                            <td class="dg_headerstyle" width="5%">
                            
                                序号</td>
                                
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('snumber','<%=OrderTool.getOrderNum("snumber",orderName,orderNum)%>');">课题编号&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("snumber",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="20%">
                                <a href="javaScript:orderPage('subjectname','<%=OrderTool.getOrderNum("subjectname",orderName,orderNum)%>');">课题名称&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("subjectname",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('state','<%=OrderTool.getOrderNum("state",orderName,orderNum)%>');">当前状态&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("state",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="10%">
                                负责人</td>
                            <td class="dg_headerstyle">
                                牵头单位</td>
                            <td class="dg_headerstyle">
                                课题来源</td>
                                <!--  <td class="dg_headerstyle" nowrap>
                                申报日期 </td>--> 
                             <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('startdate','<%=OrderTool.getOrderNum("startdate",orderName,orderNum)%>');">计划开始日期&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("startdate",orderName,orderNum))%></a></td>
                                  <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('enddate','<%=OrderTool.getOrderNum("enddate",orderName,orderNum)%>');">计划结束日期&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("enddate",orderName,orderNum))%></a></td> 
                                 <td class="dg_headerstyle" nowrap>
                                查 看</td>  
                        </tr>
                        <%if(null != resultList && resultList.size()> 0){
                            for(int i = 0;i < resultList.size();i++){
                                    Subject obj = (Subject)resultList.get(i); 
                                    boolean flag = false; 
                                    if(authFlag){
                                    	flag = true;
                                    }else{
                                  	 if(null != obj.getSubRes()){
                                  		 Set set = obj.getSubRes();
                                  		 if(null != set ){
                                  			 Iterator iter = set.iterator();
                                  			 while(iter.hasNext()) {
                                  				 SubRes sr = (SubRes)iter.next();
                                  				 Researcher re = sr.getRes();
                                  				 if(null != re && (re.getIds()+"").equals(researcher.getIds()+"")){
      	                            				 if(null != sr && ("1".equals(sr.getIsModify()+"")||"1".equals(sr.getResRole()))){
      	                            					 flag = true;
      	                            					 break;
      	                            				 }
                                  				 }
                                  			 }
                                  		 }
                                  			 
                                  	 }
                                    }
                         %>
                        <tr class="dg_alternatingitemstyle" onmouseover="ChangeRowBg(this);" onmouseout="ChangeRowBg(this);" onmouseup="ChangeRowBg(this);" onmousedown="ChangeRowBg(this);">
                            <td align="center">
                            <%if(obj.getAccessorys().size()>0){ %>
                            <img src="<%=path %>/index/Images/clip_1.gif"/>
                            <%} %>
                            <%= perpageCount*(currentPage-1)+i+1 %></td>
                            <td align="center" >
                             <%=StringUtilTool.NULL2Blank(obj.getSnumber()) %>
                            </td>
                            <td >
                            <%if(flag){ %>
                                 <a href="#"   onclick="openwindow('<%=path %>/subjectToAdd.htm?action=viewSubject&id=<%=obj.getId() %>','','','')"> <%=StringUtilTool.NULL2Blank(obj.getSubjectname()) %></a>
                                 <%}else{ %>
                                 <%=StringUtilTool.NULL2Blank(obj.getSubjectname()) %>
                                 <%} %>
                            </td>
                            <td align="center">
                                <font color="red"><%=Constants.getSubjectStatus(obj.getState()) %></font>
                            </td>
                            <td>
                               <%
                                   if(obj != null){
                                     Set res = obj.getSubRes();
                                     Iterator it = res.iterator();
                                     int j = 0;
                                     while(it.hasNext()){
                                    	
                                         SubRes rearcher = (SubRes)it.next();
                                         if(Constants.researcher_role_chargeman.equals(rearcher.getResRole()+"")){
                                        	 j++;
                                        	 out.println(rearcher.getRes()==null?"":rearcher.getRes().getName()+"&nbsp;"); 
                                         }
                                        // if(j>1)
                                        //	 out.println(",");
                                     }
                                   } 
                                 %></td>
                            <td>
                                <%
                                   if(obj != null){
                                     Set orgs = obj.getSubOrg();
                                     Iterator it = orgs.iterator();
                                     int h = 0; 
                                     while(it.hasNext()){
                                    	
                                         SubOrg org = (SubOrg)it.next();
                                         if(Constants.org_role_leader.equals(org.getOrgRole()+"")&&org.getOrg()!=null){
                                        	 out.println(org.getOrg()==null?"":org.getOrg().getName()+"&nbsp;"); 
                                         	 h++;
                                         }
                                          
                                     }
                                     
                                   } 
                                 %>
                            </td>
                            <td>
                                 <%
                                   if(obj != null){
                                     Set tags = obj.getTags();
                                     Iterator ittag = tags.iterator();
                                     while(ittag.hasNext()){
                                    	 SubTag tag = (SubTag)ittag.next();
                                         if(null != tag && tag.getTag() != null && tag.getTag().getTagType() == 1)
                                         	out.println( tag.getTag().getName());
                                     }
                                   } 
                                 %>
                            </td>
                            <!-- <td>
                                <%=Tools.getDateStringByDate1(obj.getApplydate()) %>
                            </td>-->
                            <td align="center" width="5%">
                                <%=Tools.getDateStringByDate1(obj.getStartdate()) %>
                            </td> 
                            <td align="center" width="5%">
                                 <%=Tools.getDateStringByDate1(obj.getEnddate()) %>
                            </td>
                            <td align="center" width="5%">
                                 <%if(flag){ %> <a href="#"   onclick="openwindow('<%=path %>/subjectToAdd.htm?action=viewSubject&id=<%=obj.getId() %>','','','')"><img src="<%=path %>/index/Themes/com/zoom_16x16.gif" alt="查看"  style="cursor:hand" /></a>
                                 <%}else{ %>
                                 &nbsp;
                                 <%} %>
                            </td> 
                        </tr> 
                        <%}}else{%>
                         <tr class="dg_alternatingitemstyle"> 
                            <td align="center" colspan=12>
                                <font color="red">没有找到记录</font>
                            </td> 
                        </tr> 
                        <%}%>
                    </table>
                    </form>
                    <div class="dg_pagerstyle" align="right"> 
                            <%=pageStr %>  
                    </div> 
                </div>
            </td>
        </tr>
    </table>
</body>
</html> 
